//
//  ChooseDirectionView.m
//  Runone
//
//  Created by ekkaLyn on 2017/3/14.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "ChooseDirectionView.h"
#import "SDAutoLayout.h"

@interface ChooseDirectionView ()



@property (nonatomic, copy) NSString *leftTitleStr;
@property (nonatomic, copy) NSString *contentStr;

@end

@implementation ChooseDirectionView

//收费事件上报
- (ChooseDirectionView *) initWithDefalutHeight:(CGFloat) height title:(NSString *)titleStr{
    _leftTitleStr = titleStr;
    return [self initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, height)];
}


//设置尺寸
-(instancetype)initWithFrame:(CGRect)frame {
    self=[super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor colorWithRed:226.0 / 255 green:230.0 / 255 blue:240.0 / 255 alpha:1]];
        
        [self configUI];
        [self layoutUI];
    }
    return self;
}
//配置UI
- (void) configUI {
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = [UIFont systemFontOfSize:15];
    _titleLabel.textAlignment = NSTextAlignmentRight;
    _titleLabel.text = _leftTitleStr;
    
    _chooseDirectBtn = [[UIButton alloc] init];
    _chooseDirectBtn.backgroundColor          = [UIColor clearColor];
    
    _directionLabel = [[UILabel alloc] init];
    _directionLabel.font            = [UIFont systemFontOfSize:15];
    _directionLabel.textColor       = [UIColor blackColor];
    _directionLabel.backgroundColor = [UIColor whiteColor];
    
    _lineView   = [UIView new];
    _lineView.backgroundColor = [UIColor whiteColor];
    [self sd_addSubviews:@[self.titleLabel, self.chooseDirectBtn,self.lineView,self.directionLabel]];
}

//加载UI
- (void) layoutUI {
    self.titleLabel.sd_layout
    .leftSpaceToView(self, 0)
    .topSpaceToView(self, 10)
    .heightIs(34)
    .widthIs(110)
    ;
    
    self.chooseDirectBtn.sd_layout
    .leftSpaceToView(self.titleLabel, 8)
    .rightSpaceToView(self, 8)
    .topSpaceToView(self, 8)
    .heightIs(34);
    ;
    
    self.directionLabel.sd_layout
    .leftSpaceToView(self.titleLabel, 8)
    .rightSpaceToView(self, 8)
    .topSpaceToView(self, 10)
    .heightIs(34);
    ;
    
    self.lineView.sd_layout
    .leftSpaceToView(self, 8)
    .rightSpaceToView(self, 8)
    .heightIs(1)
    .topSpaceToView(self.titleLabel, 9)
    ;
    
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:0];
}
#pragma mark -  设置

- (void) setContentString:(NSString *)str {
//    [_chooseDirectBtn setTitle:str forState:UIControlStateNormal];
    self.directionLabel.text = str;
}

@end
